package com.wuyou.text;

import com.wuyou.domain.po.MongoHouse;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.geo.Point;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

import java.util.List;

@SpringBootTest
public class TextMongo {

    @Autowired
    private MongoTemplate mongoTemplate;

    @Test
    public void testFind() {

        Query query = Query.query(Criteria.where("loc").near(new Point(116.39130038327966, 39.992994566189)).maxDistance(10 / 111.12));

        List<MongoHouse> list = mongoTemplate.find(query, MongoHouse.class);

        System.out.println(list);
    }
}
